package com.ydsungan.daoimpl;

import com.ydsungan.bean.Signin;
import com.ydsungan.bean.Student;
import com.ydsungan.dao.StudentDao;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import java.util.List;
import java.util.Map;

public class StudentDaoImpl implements StudentDao {

    SqlSessionFactory sqlSessionFactory = null;
    public StudentDaoImpl(SqlSessionFactory sqlSessionFactory) {
        this.sqlSessionFactory = sqlSessionFactory;

    }

    @Override
    public Student findStudentByMap(Map<String, Object> map) {
        SqlSession sqlSession = sqlSessionFactory.openSession();
        Student student = sqlSession.selectOne("findStudentByMap", map);
        sqlSession.close();
        return student;
    }

    @Override
    public List<Student> findAllStudent() {
        SqlSession sqlSession = sqlSessionFactory.openSession();
        List<Student> list = sqlSession.selectList("findAllStudents");
        sqlSession.close();
        return list;
    }
}
